Skip to content

Fix encoding warnings with PEP 597 enabled#398

Merged
Secrus merged 2 commits intopython-poetry:mainfrom
danyeaw:fix-encoding-warnings
Feb 8, 2024
Merged

Fix encoding warnings with PEP 597 enabled#398
Secrus merged 2 commits intopython-poetry:mainfrom
danyeaw:fix-encoding-warnings

Conversation

@danyeaw
Copy link
Copy Markdown
Contributor

@danyeaw danyeaw commented Jan 21, 2024

This PR fixes Encoding Warnings with PEP 597 warnings enabled and enables the warnings in CI. It goes along with python-poetry/poetry#8893 and python-poetry/poetry-core#685.

@danyeaw danyeaw force-pushed the fix-encoding-warnings branch from 46fef2a to 7396086 Compare January 21, 2024 21:37
@danyeaw danyeaw force-pushed the fix-encoding-warnings branch from 7396086 to ae23f60 Compare January 21, 2024 21:38
@johnslavik
Copy link
Copy Markdown
Member

johnslavik commented Jan 21, 2024

The contrib is overall a good idea.
I would only say that having to specify the encoding parameter when "opening" /dev/null seems a bit... nonsensical, i.e. it doesn't reflect the motivation behind PEP 597.

@johnslavik johnslavik requested a review from Secrus January 21, 2024 22:35
@danyeaw
Copy link
Copy Markdown
Contributor Author

danyeaw commented Jan 23, 2024

@bswck I think the idea is that for every open statement we explicitly declare whether the encoding is "utf-8" or "locale", but I agree that /dev/null probably doesn't need an encoding. Do you think it is an issue that we are explicit even with this one?

@Secrus Secrus merged commit d091b7c into python-poetry:main Feb 8, 2024
@danyeaw danyeaw deleted the fix-encoding-warnings branch February 8, 2024 23:12
@danyeaw
Copy link
Copy Markdown
Contributor Author

danyeaw commented Feb 8, 2024

Thanks @Secrus!

@radoering
Copy link
Copy Markdown
Member

I noticed that there is still one open warning:

home/runner/work/cleo/cleo/src/cleo/io/outputs/stream_output.py:53: EncodingWarning: UTF-8 Mode affects locale.getpreferredencoding(). Consider locale.getencoding() instead.

I'm not sure if we even want UTF-8 Mode to affect it. In any case, I think we should decide between:

  • Suppress this warning because locale.getpreferredencoding() is what we want.
  • Use getencoding() for Python 3.11 and above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants